<html>
<head>
<title>Debugging subcircuits</title>
</head>

<body bgcolor="FFFFFF">

<h1>Debugging subcircuits</h1>

<p>As you test larger circuits, you will likely find bugs. To nail down
what's going wrong, exploring what's going on in the subcircuits while
running the overall circuit can help. To enter the subcircuit's state, you can
use any of three different techniques. The most straightforward is probably
to view the simulation hierarchy by clicking the second icon in the explorer
pane's upper toolbar (<img src="../../../icons/projsim.gif">), or by selecting
"View Simulation Tree" from the Project menu. This switches
the explorer pane so that it shows the hierarchy of subcircuits being simulated.</p>
<center><img src="../../../img-guide/subcirc-hierarchy.png"></center>
<p>Double-clicking an element in this hierarchy will display what is happening
inside that subcircuit.</p>

<p>The second way you can enter a subcircuit is to bring up its popup menu
by right-clicking or control-clicking it, and then choosing the View option.</p>
<center><img src="../../../img-guide/subcirc-4-delve.png"></center>
<p>And the third way is to first ensure the Poke Tool is selected
and then click the subcircuit you want to enter;
a magnifying glass will appear over the subcircuit's center, and
double-clicking the magnifying glass will enter
the subcircuit's state.</p>

<p>In any case, once you enter the subcircuit, you'll see that the pins' values
in the subcircuit match the values being sent through them from the containing
circuit.</p>
<center><img src="../../../img-guide/subcirc-2-delve.png"></center>

<p>While in the subcircuit, you are allowed to alter the circuit. If the
changes affect any of the subcircuit's outputs, they are propagated into the
containing circuit. One exception: The subcircuit inputs are determined based on
the values coming into the circuit from the supercircuit, so it doesn't make
sense to toggle those values. If you attempt to poke a subcircuit's input,
a dialog will pop up asking, <q>The pin is tied to the supercircuit state.
Create a new circuit state?</q> Clicking No will cancel the toggle request,
while clicking Yes will create a copy of the viewed state,
divorced from the outer circuit, with the input pin toggled.</p>

<p>Once you have completed viewing and/or editing, you can return to the parent circuit
either by double-clicking the parent circuit in the explorer pane, or via the Go Out
To State submenu of the Simulate menu.</p>

<p><strong>Next:</strong> <a href="library.html">Logisim libraries</a>.</p>

</body>
</html>
